<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="CloudStorage.*" %>
<%
int size = 0;
if (session.getAttribute("cart") != null) {
size = ((Cart) session.getAttribute("cart")).getSize();
}
%>
<html>
    <head>
        <title>CloudShare - Edit Folder</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="style.css" />
        <link rel="stylesheet" type="text/css" href="styles/editfolder.css" />
        <link rel="SHORTCUT ICON" href="images/favicon.ico" />        
        <style type="text/css">
            <!--
            #main .inside .block1 {
                text-align: left;
                clear: none;
                float: left;
                margin-left: 250px;
                height: 200px;
            }
            body,td,th {
                color: #64584C;
            }
#main .inside #file-list a {
	color: #64584C;
	text-decoration:none;
}
		
            -->
        </style>
    </head>

    <body>
        <div id="header">
            <div class="inside"> <a href="#" class="logo"><img src="images/logo2.gif" alt="" width="131" height="83" /></a>
                <div id="content">
                </div>
                <p class="slogan">Share on Clouds!</p>
                <div id="cart">
                    <ul>
                        <li><a href="downloadcart.jsp"><img alt="cart" src="images/cart.png">  Download Cart (<%=size%>)</a> </li>
                    </ul>
                </div>
                <a href="faq.jsp" class="rss"><img src="images/rss.jpg" alt="" width="39" height="41" /></a>
            </div>
            <div id="menu">
                <% if (session.getAttribute("status") == null) {%>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="login.jsp"><img src="images/but_login.jpg" alt="" width="147" height="40" /></a></li>
                    <li><a href="register.jsp"><img src="images/but_reg.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>

                </ul>
                <% } else { %>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="account.jsp"><img src="images/but_account.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="LogoutServlet"><img src="images/but_logout.jpg" alt="" width="147" height="40" /></a></li>
                </ul>
                <%}%>

            </div>
            <div class="headimage">
                <img src="images/picture.jpg" alt="" /> </div>
        </div>
        <div class="inside">

        </div>
        <div id="main">
            <div class="inside">
                <div id="cpanel">
                    <h1><img src="images/cpanel.png" width="40" height="20">User panel</h1>
                    <ul>
                        <li></li>
                        <li><img src="images/myaccount-icon.png" width="20" height="20"> <a href="account.jsp">My Account</a></li>
                        <li><img src="images/uploads_icon.png" width="20" height="20" ><a href="myuploads.jsp"> My Uploads</a></li>
                        <li><img src="images/uploadicon.png" width="20" height="20"><a href="upload.jsp"> Upload File</a></li>
                        <li><img src="images/cart.png" width="20" height="20"><a href="downloadcart.jsp"> Download Cart</a></li>
                        <li><img src="images/buy_icon.png" alt="" width="20" height="20"><a href="buy.jsp">Buy more Space</a></li>
                    </ul>
                    <span><a href="LogoutServlet"> <img src="images/logout.png"/></a></span>
                </div>
                <div id="blocks">
                   
                    <div class="upload">
                        <%  Database database = new Database();
                        String folderName = request.getParameter("foldername");
                        ArrayList<File> files = database.getByDirectory(folderName);
                        %>
                        <h2>Edit Folder : <%= folderName %></h2>
                        <div id="upload-img"><img src="images/document_edit.png" width="128" height="128"></div>
                        <div id="upload-text">
							
								<form method="post" action="EditFolderServlet?oldname=<%= folderName %>">
                                <table>
                                    <tr><td >Folder</td>
                                        <td ><%= folderName %></td>
                                    </tr>
                                    <tr>
                                    <td>Rename Folder:</td>
                                        <td>
                                            <input name="newname" type="text" size="5">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <a href="myuploads.jsp"><img src="images/cancel.png"></a>
                                        </td>
                                        <td>
                                            <input type="image" name="submit" src="images/save.png">
                                        </td>
                                    </tr>
                                </table>
                             </form>
                                <p><img src="images/back.png" width="25" height="23"onclick="history.back()">Back to My Uploads</p>

                        </div>
                    </div>
                </div>
                <div id="file-list">
                    <h2>File List</h2>
                    <table width="100%" border="0">
                        <tr>
                            <td align="center" width="90" class="first">Date</td>
                            <td align="center" width="120" class="first">Directory</td>
                            <td align="center" width="120" class="first">Filename</td>
                            <td align="center" width="80" class="first">Category</td>
                            <td align="center" width="80" class="first">Type</td>
                            <td align="center" width="40" class="first">Price</td>
                            <td align="center" width="80" class="first">Downloads</td>
                            <td>&nbsp;</td>
                        </tr>
                         <%
                            for (int i = 0; i < files.size(); i++) {
                        %>
                        <tr>
                            <td align="center"><%= files.get(i).getDatePublished()%></td>
                            <td align="center"><%= files.get(i).getFolder() %></td>
                            <td align="center"><a href="viewfile.jsp?fileid=<%=files.get(i).getID() %>"><%= files.get(i).getName()%></a></td>

                            <td align="center">
                                <%  if (files.get(i).getCategory().equalsIgnoreCase("video")) {
                                %>
                                <img src="images/video.gif" width="15" height="20">
                                <%} else if (files.get(i).getCategory().equalsIgnoreCase("document")) {
                                %>
                                <img src="images/doc.gif" width="15" height="20">
                                <%  } else if (files.get(i).getCategory().equalsIgnoreCase("music")) {
                                %>
                                <img src="images/music.gif" width="15" height="20">
                                <%  } else if (files.get(i).getCategory().equalsIgnoreCase("other")) {
                                %>
                                <img src="images/other.gif" width="15" height="20">
                                <%  }%>
                            </td>
                            <td align="center"><%= files.get(i).getStatus()%></td>
                            <td align="center"><%= files.get(i).getValue()%></td>
                            <td align="center"><%= files.get(i).getDownloads()%></td>

                            <td><a href="editfile.jsp?fileid=<%=files.get(i).getID() %>"><img src="images/document_edit.png" width="25" height="25"></a></td>
                        </tr>
                        <%}%>
                    </table>
                    <a name="results"></a>

                </div>

            </div>

        </div>
        <div id="footer">
            <div class="inside">
                <p>CloudShare &copy; 2010   |  Webdesign by Panoylhs &amp; Roumdic S.A.</p>
            </div>
        </div>
    </body>
</html>
